package cn.edu.scau.cmi.zengdefeng.Composite;

import java.util.HashSet;
import java.util.Set;

public abstract class ConsistentComponent {
	
	private String name;
	//	(1)父节点。
	private ConsistentComponent parent=null;
	

	//	(2)子节点作为其组成部分。
	Set<ConsistentComponent> children=new HashSet<ConsistentComponent>();
	public ConsistentComponent(ConsistentComponent parent,String name) {
		this.setName(name);
		this.setParent(parent);
	}
	

	//	(3)业务功能
	 abstract String toString(int cent);
	
	//	(4)对包含对象的功能


	//	(5)对构成部分管理的功能，这些和安全性组合模式不同
	public void addChild(ConsistentComponent child) {
		children.add(child);
	};
	public void deleteChild(ConsistentComponent child) {
		children.remove(child);
	};
	public  Set<ConsistentComponent> getChildren(){
		return children;
	};
	public void setChildren(Set<ConsistentComponent> children) {
		this.children=children;
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public ConsistentComponent getParent() {
		return parent;
	}


	public void setParent(ConsistentComponent parent) {
		this.parent = parent;
	}

}